﻿using Microsoft.EntityFrameworkCore.Migrations;
using TiaoTaoHelper.Wtm.Units.EFCore;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 访客中心绑定微信用户更改为系统用户 : TransactionalMigration
    {
        /// <inheritdoc />
        protected override void UpWithTransaction(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysVisitorInformation_SysWechatUser_WechatUserId",
                table: "SysVisitorInformation");

            migrationBuilder.RenameColumn(
                name: "WechatUserId",
                table: "SysVisitorInformation",
                newName: "UserId");

            migrationBuilder.RenameIndex(
                name: "IX_SysVisitorInformation_WechatUserId",
                table: "SysVisitorInformation",
                newName: "IX_SysVisitorInformation_UserId");

            migrationBuilder.AlterColumn<bool>(
                name: "IsActive",
                table: "SysVisitorReason",
                type: "bit",
                nullable: false,
                oldClrType: typeof(int),
                oldType: "int");

            migrationBuilder.AlterColumn<bool>(
                name: "BlackStatus",
                table: "SysVisitorInformation",
                type: "bit",
                nullable: false,
                defaultValue: false,
                oldClrType: typeof(int),
                oldType: "int",
                oldNullable: true);

            migrationBuilder.AddForeignKey(
                name: "FK_SysVisitorInformation_FrameworkUsers_UserId",
                table: "SysVisitorInformation",
                column: "UserId",
                principalTable: "FrameworkUsers",
                principalColumn: "ID");
        }

        /// <inheritdoc />
        protected override void DownWithTransaction(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysVisitorInformation_FrameworkUsers_UserId",
                table: "SysVisitorInformation");

            migrationBuilder.RenameColumn(
                name: "UserId",
                table: "SysVisitorInformation",
                newName: "WechatUserId");

            migrationBuilder.RenameIndex(
                name: "IX_SysVisitorInformation_UserId",
                table: "SysVisitorInformation",
                newName: "IX_SysVisitorInformation_WechatUserId");

            migrationBuilder.AlterColumn<int>(
                name: "IsActive",
                table: "SysVisitorReason",
                type: "int",
                nullable: false,
                oldClrType: typeof(bool),
                oldType: "bit");

            migrationBuilder.AlterColumn<int>(
                name: "BlackStatus",
                table: "SysVisitorInformation",
                type: "int",
                nullable: true,
                oldClrType: typeof(bool),
                oldType: "bit");

            migrationBuilder.AddForeignKey(
                name: "FK_SysVisitorInformation_SysWechatUser_WechatUserId",
                table: "SysVisitorInformation",
                column: "WechatUserId",
                principalTable: "SysWechatUser",
                principalColumn: "ID");
        }
    }
}
